﻿/* PC INpact App for Chrome™

	PC INpact App for Chrome™ est une application destinée au Chrome Web Store permettant d'acchéder à PC INpact.
	Elle dispose de fonctionnalités spécifiques, telles que la notification de nouvelles actualités, dossiers...

	Main author : LEGRAND David
	Mail : david@pcinpact.com
	
	Google Code Project : http://pci.im/code-pci-chrome 
	Forum : http://pci.im/forum-pci-chrome
	
    This file is part of PC INpact App for Chrome™.

    PC INpact App for Chrome™ is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    PC INpact App for Chrome™ is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PC INpact App for Chrome™.  If not, see <http://www.gnu.org/licenses/>. 

    You're not allowed to use PC INpact App for Chrome™ name or logo without permission */
	
// La fonction gérant les requêtes sur une URL externe de manière synchrone
function ext_req(url, xml) {

	// On traite la requête
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET", url, false);
	xmlhttp.send(null);
	
	// Si l'on a demandé un objet XML, on le renvoie, sinon on renvoie un texte
	if (xml) return xmlhttp.responseXML;
	else return xmlhttp.responseText;
}

// La fonction qui récupère le Header depuis une URL
function ext_req_head(url, xml) {

	// On traite la requête
	var xmlhttp = new XMLHttpRequest();
	xmlhttp.open("HEAD", url, false);
	xmlhttp.send(null);
	
	return xmlhttp.getAllResponseHeaders();
}

// La fonction d'extraction des paramètres
function extract(chaine, start, end, nb)
{
	var first_index = chaine.indexOf(start);
	var result_temp = chaine.substring(first_index + nb);
	var second_index = result_temp.indexOf(end);
	return result_temp.substring(0, second_index);
}